In [1]:
import sys, os
import numpy as np
import matplotlib.pyplot as plt

# Import the aims module
from soma import aims
# the brainplot package
import colorado as cld

print(sys.version)
3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0]

Visualize pyAims Object

Colorado has a draw function that choses the best representation according to the type of the first calling argument. The object that can be drawn are:

  • bucketsMaps: pyaims.BucketMap (the points coordinates are rescaled according to the voxel size in the Map header)
  • buckets: pyaims.Bucket (the points are shown in their row coordinates)
  • volumes: pyaims.Volume
  • meshes: pyaims.TimeSurface

for each of these objects a more specific function exist that has more adcanced options (e.g. cld.draw_volume).

The draw() function can plot numpy arrays, in this case the type of object is inferred by the array dimensions:

  • a (N,3) array is dispayed as bucket
  • a (L,N,M) array is displayed as volume

Buckets

Sets of points defined by their 3D coordinates

In [20]:
bucket_map = aims.read('../data/LAbby_New.bck')
cld.draw(bucket_map)

Volumes

Representation of voxel images. Voxel images are represented in the same way as buckets, i.e. with a set of points.

In [36]:
vol = aims.read('../data/subject01.nii')
cld.draw(vol,
         downsample=2,     # downsample the voxels in the volume
         max_points=5000,  # number of randomly sampled points to plot (low => fast)
         th_min=950,       # voxels below this value will not be plotted
         th_max=1000       # voxels above this value will not be plotted
)

Meshes

Meshes are surfaces represented as a set of simple polygons.

In [38]:
meshR = aims.read('../data/subject01_Rhemi.mesh')
meshL = aims.read('../data/subject01_Lhemi.mesh')
cld.draw([meshL, meshR])

Plotting options and Makeup

Any optional argument passed to draw() which is not defined in the prototype, is directly passed to the underlying Plotly function.

For example the marker argument can be used to change size, shape and color of the points in a bucket plot.

See "3D Scatter Plot" in Plotly's documentation for a complete definition of all available options.

In [33]:
cld.draw(bucket_map, marker=dict(color='red'))